<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>01-博客搭建_hexo篇 | MyBlog</title>
  <meta name="keywords" content=" 工具 ">
  <meta name="description" content="01-博客搭建_hexo篇 | MyBlog">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta property="og:type" content="website">
<meta property="og:title" content="about">
<meta property="og:url" content="http://example.com/about/index.html">
<meta property="og:site_name" content="MyBlog">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2022-02-20T11:23:48.000Z">
<meta property="article:modified_time" content="2022-02-20T11:24:55.686Z">
<meta property="article:author" content="杨">
<meta name="twitter:card" content="summary">


<link rel="icon" href="/img/avatar.jpg">

<link href="/css/style.css?v=1.1.0" rel="stylesheet">

<link href="/css/hl_theme/kimbie-light.css?v=1.1.0" rel="stylesheet">

<link href="//cdn.jsdelivr.net/npm/animate.css@4.1.0/animate.min.css" rel="stylesheet">

<link href="//cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css" rel="stylesheet">
<link href="//cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.min.css" rel="stylesheet">

<script src="//cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script>
<script src="/js/titleTip.js?v=1.1.0" ></script>

<script src="//cdn.jsdelivr.net/npm/highlightjs@9.16.2/highlight.pack.min.js"></script>
<script>
    hljs.initHighlightingOnLoad();
</script>

<script src="//cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.min.js"></script>



<script src="//cdn.jsdelivr.net/npm/jquery.cookie@1.4.1/jquery.cookie.min.js" ></script>

<script src="/js/iconfont.js?v=1.1.0" ></script>

<meta name="generator" content="Hexo 6.0.0"></head>
<div style="display: none">
  <input class="theme_disqus_on" value="false">
  <input class="theme_preload_comment" value="">
  <input class="theme_blog_path" value="">
  <input id="theme_shortcut" value="true" />
  <input id="theme_highlight_on" value="true" />
  <input id="theme_code_copy" value="true" />
</div>



<body>
<aside class="nav">
    <div class="nav-left">
        <a href="/"
   class="avatar_target">
    <img class="avatar"
         src="/img/avatar.jpg"/>
</a>
<div class="author">
    <span>杨</span>
</div>

<div class="icon">
    
        
            <a title="rss"
               href="/atom.xml"
               target="_blank">
                
                    <svg class="iconfont-svg" aria-hidden="true">
                        <use xlink:href="#icon-rss"></use>
                    </svg>
                
            </a>
        
    
        
            <a title="github"
               href="https://github.com/yelog"
               target="_blank">
                
                    <svg class="iconfont-svg" aria-hidden="true">
                        <use xlink:href="#icon-github"></use>
                    </svg>
                
            </a>
        
    
        
            <a title="facebook"
               href="https://www.facebook.com/faker.tops"
               target="_blank">
                
                    <svg class="iconfont-svg" aria-hidden="true">
                        <use xlink:href="#icon-facebook"></use>
                    </svg>
                
            </a>
        
    
        
    
        
    
        
            <a title="instagram"
               href="https://www.facebook.com/faker.tops"
               target="_blank">
                
                    <svg class="iconfont-svg" aria-hidden="true">
                        <use xlink:href="#icon-instagram"></use>
                    </svg>
                
            </a>
        
    
        
            <a title="reddit"
               href="https://www.reddit.com/user/yelog/"
               target="_blank">
                
                    <svg class="iconfont-svg" aria-hidden="true">
                        <use xlink:href="#icon-reddit"></use>
                    </svg>
                
            </a>
        
    
        
            <a title="weibo"
               href="http://weibo.com/u/2307534817"
               target="_blank">
                
                    <svg class="iconfont-svg" aria-hidden="true">
                        <use xlink:href="#icon-weibo"></use>
                    </svg>
                
            </a>
        
    
        
            <a title="jianshu"
               href="https://www.jianshu.com/u/ff56736de7cf"
               target="_blank">
                
                    <svg class="iconfont-svg" aria-hidden="true">
                        <use xlink:href="#icon-jianshu"></use>
                    </svg>
                
            </a>
        
    
        
            <a title="zhihu"
               href="https://www.zhihu.com/people/jaytp/activities"
               target="_blank">
                
                    <svg class="iconfont-svg" aria-hidden="true">
                        <use xlink:href="#icon-zhihu"></use>
                    </svg>
                
            </a>
        
    
        
    
        
            <a title="oschina"
               href="https://my.oschina.net/yelog"
               target="_blank">
                
                    <svg class="iconfont-svg" aria-hidden="true">
                        <use xlink:href="#icon-oschina"></use>
                    </svg>
                
            </a>
        
    
        
    
        
            <a title="email"
               href="mailto:9723@qq.com"
               target="_blank">
                
                    <svg class="iconfont-svg" aria-hidden="true">
                        <use xlink:href="#icon-email"></use>
                    </svg>
                
            </a>
        
    
        
            <a title="qq"
               href="http://wpa.qq.com/msgrd?v=3&uin=9723&site=qq&menu=yes"
               target="_blank">
                
                    <svg class="iconfont-svg" aria-hidden="true">
                        <use xlink:href="#icon-qq"></use>
                    </svg>
                
            </a>
        
    
        
            <a title="kugou"
               href="https://www.kugou.com/"
               target="_blank">
                
                    <svg class="iconfont-svg" aria-hidden="true">
                        <use xlink:href="#icon-kugou"></use>
                    </svg>
                
            </a>
        
    
        
            <a title="neteasemusic"
               href="https://music.163.com/#/user/home?id=88151013"
               target="_blank">
                
                    <svg class="iconfont-svg" aria-hidden="true">
                        <use xlink:href="#icon-neteasemusic"></use>
                    </svg>
                
            </a>
        
    
</div>




<ul>
    <li>
        <div class="all active" data-rel="全部文章">全部文章
            
                <small>(4)</small>
            
        </div>
    </li>
    
        
            
                <li>
                    <div data-rel="博客搭建">
                        
                        博客搭建
                        <small>(3)</small>
                        
                    </div>
                    
                </li>
            
        
    
</ul>
<div class="left-bottom">
    <div class="menus">
        
            
            
            
    </div>
    <div>
        
            <a class="about  site_url"
               
               href="/about">关于</a>
        
        
    </div>
</div>
<input type="hidden" id="yelog_site_posts_number" value="4">

<div style="display: none">
    <span id="busuanzi_value_site_uv"></span>
    <span id="busuanzi_value_site_pv"></span>
</div>

    </div>
    <div class="nav-right">
        <div class="friends-area">
    <div class="friends-title">
        友情链接
        <i class="iconfont icon-left"></i>
    </div>
    <div class="friends-content">
        <ul>
            
        </ul>
    </div>
</div>
        <div class="title-list">
    <div class="right-top">
        <div id="default-panel">
            <i class="iconfont icon-search" data-title="搜索 快捷键 i"></i>
            <div class="right-title">全部文章</div>
            <i class="iconfont icon-file-tree" data-title="切换到大纲视图 快捷键 w"></i>
        </div>
        <div id="search-panel">
            <i class="iconfont icon-left" data-title="返回"></i>
            <input id="local-search-input" autocomplete="off"/>
            <label class="border-line" for="input"></label>
            <i class="iconfont icon-case-sensitive" data-title="大小写敏感"></i>
            <i class="iconfont icon-tag" data-title="标签"></i>
        </div>
        <div id="outline-panel" style="display: none">
            <div class="right-title">大纲</div>
            <i class="iconfont icon-list" data-title="切换到文章列表"></i>
        </div>
    </div>

    <div class="tags-list">
    <input id="tag-search" />
    <div class="tag-wrapper">
        
            <li class="article-tag-list-item">
                <i class="iconfont icon-tag"></i><a>博客</a>
            </li>
        
            <li class="article-tag-list-item">
                <i class="iconfont icon-tag"></i><a>工具</a>
            </li>
        
            <li class="article-tag-list-item">
                <i class="iconfont icon-tag"></i><a>图床</a>
            </li>
        
    </div>

</div>

    
    <div id="local-search-result">

    </div>
    
    <nav id="title-list-nav">
        
        <a  class="全部文章 博客搭建 "
           href="/2022/02/21/03-%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA-typora%E5%9B%BE%E5%BA%8A/"
           data-tag="博客,图床"
           data-author="" >
            <span class="post-title" title="03-博客搭建_typora图床">03-博客搭建_typora图床</span>
            <span class="post-date" title="2022-02-21 17:59:11">2022/02/21</span>
        </a>
        
        <a  class="全部文章 博客搭建 "
           href="/2022/02/21/02-%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA-GitHub%E7%AF%87/"
           data-tag="工具"
           data-author="" >
            <span class="post-title" title="02-博客搭建_GitHub篇">02-博客搭建_GitHub篇</span>
            <span class="post-date" title="2022-02-21 16:08:03">2022/02/21</span>
        </a>
        
        <a  class="全部文章 博客搭建 "
           href="/2022/02/21/01-%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA-hexo%E7%AF%87/"
           data-tag="工具"
           data-author="" >
            <span class="post-title" title="01-博客搭建_hexo篇">01-博客搭建_hexo篇</span>
            <span class="post-date" title="2022-02-21 15:30:33">2022/02/21</span>
        </a>
        
        <a  class="全部文章 "
           href="/2022/02/20/hello-world/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="Hello World">Hello World</span>
            <span class="post-date" title="2022-02-20 17:23:17">2022/02/20</span>
        </a>
        
        <div id="no-item-tips">

        </div>
    </nav>
    <div id="outline-list">
    </div>
</div>

    </div>
    <div class="hide-list">
        <div class="semicircle" data-title="切换全屏 快捷键 s">
            <div class="brackets first"><</div>
            <div class="brackets">&gt;</div>
        </div>
    </div>
</aside>
<div id="post">
    <div class="pjax">
        <article id="post-01-博客搭建-hexo篇" class="article article-type-post" itemscope itemprop="blogPost">
    
        <h1 class="article-title">01-博客搭建_hexo篇</h1>
    
    <div class="article-meta">
        
        
        
        <span class="book">
            <i class="iconfont icon-category"></i>
            
            
            <a  data-rel="博客搭建">博客搭建</a>
            
        </span>
        
        
        <span class="tag">
            <i class="iconfont icon-tag"></i>
            
            <a class="color3">工具</a>
            
        </span>
        
    </div>
    <div class="article-meta">
        
            发布时间 : <time class="date" title='最后更新: 2022-02-21 15:56:33'>2022-02-21 15:30</time>
        
    </div>
    <div class="article-meta">
        
        
        <span id="busuanzi_container_page_pv">
            阅读 :<span id="busuanzi_value_page_pv">
                <span class="count-comment">
                    <span class="spinner">
                      <div class="cube1"></div>
                      <div class="cube2"></div>
                    </span>
                </span>
            </span>
        </span>
        
        
    </div>
    
    <div class="toc-ref">
    
        <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%BB%8E%E9%9B%B6%E5%BC%80%E5%A7%8B%E5%85%8D%E8%B4%B9%E6%90%AD%E5%BB%BA%E8%87%AA%E5%B7%B1%E7%9A%84%E5%8D%9A%E5%AE%A2-%E4%B8%80-%E2%80%94%E2%80%94%E6%9C%AC%E5%9C%B0%E6%90%AD%E5%BB%BAhexo%E6%A1%86%E6%9E%B6"><span class="toc-text">从零开始免费搭建自己的博客(一)——本地搭建hexo框架</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#hexo%E7%AE%80%E4%BB%8B"><span class="toc-text">hexo简介</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%89%E8%A3%85-Hexo"><span class="toc-text">安装 Hexo</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%9C%AC%E5%9C%B0%E5%8D%9A%E5%AE%A2%E6%95%88%E6%9E%9C"><span class="toc-text">本地博客效果</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%9B%B4%E6%8D%A2%E4%B8%BB%E9%A2%98"><span class="toc-text">更换主题</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#hexo-theme-3-hexo%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95"><span class="toc-text">hexo-theme-3-hexo使用方法</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%86%99%E4%BD%9C"><span class="toc-text">写作</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9C%AC%E5%9C%B0%E5%8F%91%E5%B8%83"><span class="toc-text">本地发布</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%AE%BE%E7%BD%AE%E6%96%87%E7%AB%A0%E7%9A%84%E9%93%BE%E6%8E%A5"><span class="toc-text">设置文章的链接</span></a></li></ol></li></ol></li></ol>
    
<style>
    .left-col .switch-btn,
    .left-col .switch-area {
        display: none;
    }
    .toc-level-3 i,
    .toc-level-3 ol {
        display: none !important;
    }
</style>
</div>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h1 id="从零开始免费搭建自己的博客-一-——本地搭建hexo框架"><a href="#从零开始免费搭建自己的博客-一-——本地搭建hexo框架" class="headerlink" title="从零开始免费搭建自己的博客(一)——本地搭建hexo框架"></a>从零开始免费搭建自己的博客(一)——本地搭建hexo框架</h1><h2 id="hexo简介"><a href="#hexo简介" class="headerlink" title="hexo简介"></a>hexo简介</h2><p>Hexo 中文官网：<a target="_blank" rel="noopener" href="https://hexo.io/zh-cn/">hexo.io</a> ，GitHub 地址：<a target="_blank" rel="noopener" href="https://github.com/hexojs/hexo">hexojs&#x2F;hexo</a> 。</p>
<h2 id="安装-Hexo"><a href="#安装-Hexo" class="headerlink" title="安装 Hexo"></a>安装 Hexo</h2><p>首先在本地新建一个空文件夹，用来存放 Hexo 的文件和以后要写的博客文件，注意不要有中文路径，避免可能出现的问题。</p>
<ul>
<li>进入新建 MyBlog 文件夹，右键，选择Git Bash Here，依次输入下面的命令。</li>
</ul>
<pre><code class="yaml"># 安装 hexo 框架，-g表示安装全局模块
npm install -g hexo-cli
# 初始化文件夹：会用 git clone命令去 GitHub 下载一个 hexo 默认模板代码库，保存在blog文件夹
hexo init blog
# 进入blog文件夹
cd blog
# 安装 hexo 依赖包：会根据刚下载的代码库中的配置文件，下载并安装所需依赖包
npm install
</code></pre>
<p><img src="https://gitee.com/yang-weijian/pic-go_img/raw/master/img_2022/202202201733281.png" alt="image-20220220173305203"></p>
<p><img src="https://gitee.com/yang-weijian/pic-go_img/raw/master/img_2022/202202201734306.png" alt="image-20220220173417204"></p>
<h2 id="本地博客效果"><a href="#本地博客效果" class="headerlink" title="本地博客效果"></a>本地博客效果</h2><pre><code class="yaml"># 生成静态文件
hexo g
</code></pre>
<p><img src="https://gitee.com/yang-weijian/pic-go_img/raw/master/img_2022/202202201753503.png" alt="image-20220220175302409"></p>
<pre><code class="yaml"># 运行
hexo server
</code></pre>
<p><img src="https://gitee.com/yang-weijian/pic-go_img/raw/master/img_2022/202202201738100.png" alt="image-20220220173840027"></p>
<p><img src="https://gitee.com/yang-weijian/pic-go_img/raw/master/img_2022/202202201737776.png" alt="image-20220220173748602"></p>
<h2 id="更换主题"><a href="#更换主题" class="headerlink" title="更换主题"></a>更换主题</h2><p>主题：hexo-theme-3-hexo</p>
<p><a target="_blank" rel="noopener" href="https://github.com/yelog/hexo-theme-3-hexo">地址</a></p>
<ul>
<li>在 Hexo 博客根目录(<code>D:\MyBlog\blog</code>)下，右键，选择<code>Git Bash Here</code>，执行下面命令：</li>
</ul>
<pre><code class="yaml"># 下载主题仓库到 themes 文件夹， git clone &lt;仓库地址&gt; themes/&lt;主题名&gt; 
git clone https://github.com/yelog/hexo-theme-3-hexo.git themes/3-hexo
</code></pre>
<p><img src="https://gitee.com/yang-weijian/pic-go_img/raw/master/img_2022/202202201906536.png" alt="image-20220220190655431"></p>
<ul>
<li>然后用记事本打开博客根目录下的 _config.yml (<code>D:\MyBlog\blog\_config.yml</code>)，找到<code>theme</code>标签，默认值是<code>landscape</code>主题，把它改为要更换的主题名字<code>theme: 3-hexo</code>，然后执行启动命令。</li>
</ul>
<p><img src="https://gitee.com/yang-weijian/pic-go_img/raw/master/img_2022/202202201909787.png" alt="image-20220220190903712"></p>
<pre><code class="yml"># Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: 3-hexo
</code></pre>
<ul>
<li>启动</li>
</ul>
<pre><code class="bash"># 清理 &amp;&amp; 生成 &amp;&amp; 启动
hexo clean &amp;&amp; hexo g &amp;&amp; hexo s
</code></pre>
<p><img src="https://gitee.com/yang-weijian/pic-go_img/raw/master/img_2022/202202201914183.png" alt="image-20220220191430105"></p>
<h2 id="hexo-theme-3-hexo使用方法"><a href="#hexo-theme-3-hexo使用方法" class="headerlink" title="hexo-theme-3-hexo使用方法"></a>hexo-theme-3-hexo使用方法</h2><p><a target="_blank" rel="noopener" href="http://yelog.org/2017/03/23/3-hexo-instruction/">使用说明</a></p>
<h3 id="写作"><a href="#写作" class="headerlink" title="写作"></a>写作</h3><ul>
<li><p><code>创建文件</code>，并且在创建文件时创建对应分类文件夹</p>
<p>1、设置根目录下的 <code>_config.yml</code> 文件 <code>new_post_name</code>属性（设置文件名），添加分类&#x2F;</p>
<p><img src="https://gitee.com/yang-weijian/pic-go_img/raw/master/img_2022/202202211540702.png" alt="image-20220221154005603"></p>
<p>2、git输入</p>
<pre><code class="bash">hexo new &quot;01-博客搭建_hexo篇&quot; --categories &quot;博客搭建&quot;
</code></pre>
<p><img src="https://gitee.com/yang-weijian/pic-go_img/raw/master/img_2022/202202211546930.png" alt="image-20220221154629875"></p>
<p><img src="https://gitee.com/yang-weijian/pic-go_img/raw/master/img_2022/202202211547370.png" alt="image-20220221154728299"></p>
</li>
</ul>
<h3 id="本地发布"><a href="#本地发布" class="headerlink" title="本地发布"></a>本地发布</h3><pre><code class="bash">hexo clean &amp;&amp; hexo g &amp;&amp; hexo s
</code></pre>
<h3 id="设置文章的链接"><a href="#设置文章的链接" class="headerlink" title="设置文章的链接"></a>设置文章的链接</h3><p>1、设置根目录下的 <code>_config.yml</code> 文件  <code>permalink</code> 属性</p>
<p><img src="https://gitee.com/yang-weijian/pic-go_img/raw/master/img_2022/202202211550047.png" alt="image-20220221155047950"></p>

      
       <hr><span style="font-style: italic;color: gray;"> 转载请注明来源，欢迎对文章中的引用来源进行考证，欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论，也可以邮件至 @qq.com </span>
    </div>
</article>







    




    </div>
    <div class="copyright">
        <p class="footer-entry">
    ©2022-2025 Yang
</p>
<p class="footer-entry">Built with <a href="https://hexo.io/" target="_blank">Hexo</a> and <a href="https://github.com/yelog/hexo-theme-3-hexo" target="_blank">3-hexo</a> theme</p>

    </div>
    <div class="full-toc">
        <button class="full" data-title="切换全屏 快捷键 s"><span class="min "></span></button>
<a class="" id="rocket" ></a>

    </div>
</div>

</body>
<script src="/js/jquery.pjax.js?v=1.1.0" ></script>

<script src="//cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script src="/js/script.js?v=1.1.0" ></script>
<script>
    var img_resize = 'photoSwipe';
    function initArticle() {
        /*渲染对应的表格样式*/
        
            $("#post .pjax table").addClass("green_title");
        

        /*渲染打赏样式*/
        

        /*高亮代码块行号*/
        

        /*访问数量*/
        
        $.getScript("//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js");
        

        /*代码高亮，行号对齐*/
        $('.pre-numbering').css('line-height',$('.has-numbering').css('line-height'));

        

        // PhotoSwipe
        $('article').each(function(i){
            $(this).find('img').each(function(){
                if ($(this).closest('figure').hasClass('article-gallery-img')) {
                    return;
                }
                var alt = this.alt;
                $(this)
                    .wrap('<figure class="article-gallery-img" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"></figure>')
                    .wrap('<a href="' + this.src + '" title="' + alt + '"></a>');
                $(this).after('<div class="img_alt"><span>' + (alt || '') + '</span></div>');
            });
        });

        var pswpElement = document.querySelectorAll('.pswp')[0];
        if (pswpElement) {
            var gallerySelector = '.article-gallery, article';

            var initPhotoSwipeFromDOM = function(gallerySelector) {

                // parse slide data (url, title, size ...) from DOM elements
                // (children of gallerySelector)
                var parseThumbnailElements = function(el) {
                    var thumbElements = $(el).find('figure.article-gallery-img').toArray(),
                        numNodes = thumbElements.length,
                        items = [],
                        figureEl,
                        linkEl,
                        size,
                        imgEl,
                        item;

                    for (var i = 0; i < numNodes; i++) {

                        figureEl = thumbElements[i]; // <figure> element

                        // include only element nodes
                        if (figureEl.nodeType !== 1) {
                            continue;
                        }

                        linkEl = figureEl.children[0]; // <a> element
                        imgEl = linkEl.children[0]; // <img>

                        size = linkEl.getAttribute('data-size');
                        size = size && size.split('x');

                        // create slide object
                        item = {
                            src: linkEl.getAttribute('href'),
                            w: size && parseInt(size[0], 10) || imgEl.width,
                            h: size && parseInt(size[1], 10) || imgEl.height
                        };

                        if (figureEl.children.length > 1) {
                            // <figcaption> content
                            item.title = figureEl.children[1].innerHTML;
                        }

                        if (linkEl.children.length > 0) {
                            // <img> thumbnail element, retrieving thumbnail url
                            item.msrc = linkEl.children[0].getAttribute('src');
                        }

                        item.el = figureEl; // save link to element for getThumbBoundsFn
                        items.push(item);
                    }

                    return items;
                };

                // find nearest parent element
                var closest = function closest(el, fn) {
                    return el && (fn(el) ? el : closest(el.parentNode, fn));
                };

                // triggers when user clicks on thumbnail
                var onThumbnailsClick = function(e) {
                    e = e || window.event;

                    var eTarget = e.target || e.srcElement;

                    // find root element of slide
                    var clickedListItem = closest(eTarget, function(el) {
                        return (el.tagName && el.tagName.toUpperCase() === 'FIGURE');
                    });

                    if (!clickedListItem) {
                        return;
                    }

                    if (e.preventDefault) {
                        e.preventDefault();
                    } else {
                        e.returnValue = false;
                    }

                    // find index of clicked item by looping through all child nodes
                    // alternatively, you may define index via data- attribute
                    var clickedGallery = $(clickedListItem).closest(gallerySelector)[0],
                        childNodes = $(clickedGallery).find('figure.article-gallery-img').toArray(),
                        numChildNodes = childNodes.length,
                        nodeIndex = 0,
                        index;

                    for (var i = 0; i < numChildNodes; i++) {
                        if (childNodes[i].nodeType !== 1) {
                            continue;
                        }

                        if (childNodes[i] === clickedListItem) {
                            index = nodeIndex;
                            break;
                        }
                        nodeIndex++;
                    }



                    if (index >= 0) {
                        // open PhotoSwipe if valid index found
                        openPhotoSwipe(index, clickedGallery);
                    }
                    return false;
                };

                // parse picture index and gallery index from URL (#&pid=1&gid=2)
                var photoswipeParseHash = function() {
                    var hash = window.location.hash.substring(1),
                        params = {};

                    if (hash.length < 5) {
                        return params;
                    }

                    var vars = hash.split('&');
                    for (var i = 0; i < vars.length; i++) {
                        if (!vars[i]) {
                            continue;
                        }
                        var pair = vars[i].split('=');
                        if (pair.length < 2) {
                            continue;
                        }
                        params[pair[0]] = pair[1];
                    }

                    if (params.gid) {
                        params.gid = parseInt(params.gid, 10);
                    }

                    return params;
                };

                var openPhotoSwipe = function(index, galleryElement, disableAnimation, fromURL) {
                    var pswpElement = document.querySelectorAll('.pswp')[0],
                        gallery,
                        options,
                        items;

                    items = parseThumbnailElements(galleryElement);

                    // define options (if needed)
                    options = {

                        // define gallery index (for URL)
                        galleryUID: galleryElement.getAttribute('data-pswp-uid'),

                        getThumbBoundsFn: function(index) {
                            // See Options -> getThumbBoundsFn section of documentation for more info
                            var thumbnail = items[index].el.getElementsByTagName('img')[0], // find thumbnail
                                pageYScroll = window.pageYOffset || document.documentElement.scrollTop,
                                rect = thumbnail.getBoundingClientRect();

                            return {
                                x: rect.left,
                                y: rect.top + pageYScroll,
                                w: rect.width
                            };
                        }
                    };

                    // PhotoSwipe opened from URL
                    if (fromURL) {
                        if (options.galleryPIDs) {
                            // parse real index when custom PIDs are used
                            // http://photoswipe.com/documentation/faq.html#custom-pid-in-url
                            for (var j = 0; j < items.length; j++) {
                                if (items[j].pid == index) {
                                    options.index = j;
                                    break;
                                }
                            }
                        } else {
                            // in URL indexes start from 1
                            options.index = parseInt(index, 10) - 1;
                        }
                    } else {
                        options.index = parseInt(index, 10);
                    }

                    // exit if index not found
                    if (isNaN(options.index)) {
                        return;
                    }

                    if (disableAnimation) {
                        options.showAnimationDuration = 0;
                    }

                    // Pass data to PhotoSwipe and initialize it
                    gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);

                    gallery.listen('imageLoadComplete', function(index, item) {
                        var linkEl = item.el.children[0];
                        var img = item.container.children[0];
                        if (!linkEl.getAttribute('data-size')) {
                            linkEl.setAttribute('data-size', img.naturalWidth + 'x' + img.naturalHeight);
                            item.w = img.naturalWidth;
                            item.h = img.naturalHeight;
                            gallery.invalidateCurrItems();
                            gallery.updateSize(true);
                        }
                    });

                    gallery.init();
                };

                // loop through all gallery elements and bind events
                var galleryElements = document.querySelectorAll(gallerySelector);

                for (var i = 0, l = galleryElements.length; i < l; i++) {
                    galleryElements[i].setAttribute('data-pswp-uid', i + 1);
                    galleryElements[i].onclick = onThumbnailsClick;
                }

                // Parse URL and open gallery if it contains #&pid=3&gid=1
                var hashData = photoswipeParseHash();
                if (hashData.pid && hashData.gid) {
                    openPhotoSwipe(hashData.pid, galleryElements[hashData.gid - 1], true, true);
                }
            };

            // execute above function
            initPhotoSwipeFromDOM(gallerySelector);
        }
        
        
    }

    /*打赏页面隐藏与展示*/
    

</script>

<!--加入行号的高亮代码块样式-->

<!--自定义样式设置-->
<style>
    
    
    .nav {
        width: 542px;
    }
    .nav.fullscreen {
        margin-left: -542px;
    }
    .nav-left {
        width: 120px;
    }
    
    
    @media screen and (max-width: 1468px) {
        .nav {
            width: 492px;
        }
        .nav.fullscreen {
            margin-left: -492px;
        }
        .nav-left {
            width: 100px;
        }
    }
    
    
    @media screen and (max-width: 1024px) {
        .nav {
            width: 492px;
            margin-left: -492px
        }
        .nav.fullscreen {
            margin-left: 0;
        }
    }
    
    @media screen and (max-width: 426px) {
        .nav {
            width: 100%;
        }
        .nav-left {
            width: 100%;
        }
    }
    
    
    .nav-right .title-list nav a .post-title, .nav-right .title-list #local-search-result a .post-title {
        color: #383636;
    }
    
    
    .nav-right .title-list nav a .post-date, .nav-right .title-list #local-search-result a .post-date {
        color: #5e5e5f;
    }
    
    
    .nav-right nav a.hover, #local-search-result a.hover{
        background-color: #e2e0e0;
    }
    
    

    /*列表样式*/
    

    /* 背景图样式 */
    
    


    /*引用块样式*/
    

    /*文章列表背景图*/
    
    .nav-right:before {
        content: ' ';
        display: block;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        opacity: 0.3;
        background: url("https://i.loli.net/2019/07/22/5d3521411f3f169375.png");
        background-repeat: no-repeat;
        background-position: 50% 0;
        -ms-background-size: cover;
        -o-background-size: cover;
        -moz-background-size: cover;
        -webkit-background-size: cover;
        background-size: cover;
    }
    

    
</style>


<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe.
         It's a separate element, as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. PhotoSwipe keeps only 3 slides in DOM to save memory. -->
        <!-- don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <!-- Preloader demo https://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>






</html>
